extends Node
func _init():
	pass

var skills = {
	"i_gun_381":Skill_001, "i_gun_120M1936":Skill_002, "i_gun_120":Skill_003, "i_gun_152":Skill_004, "i_gun_155":Skill_005, "i_gun_203skc":Skill_006,
	"i_gun_203mk15":Skill_007, "i_gun_406mk6":Skill_008, "i_gun_406mk5":Skill_009, "i_torpedo_533x5c":Skill_010, "i_torpedo_610x4":Skill_011,
	"i_torpedo_533mk17":Skill_012, "i_gun_381m1934":Skill_013, "i_gun_203Mle1931":Skill_014, "i_torpedo_533x4c":Skill_015, "i_torpedo_533mk9":Skill_016
}

class Skill extends Object:
	var text
	var sname
	var upgraded:bool
	var utils = globalData.infoDs["g_azurlaneUtils"]
	var buff = globalData.infoDs["g_azurlaneBuffs"]
	var cdId
	#升级进度
	var readNum = 0
	#connect记录
	var cons = []
	var tcha
	#稀有度
	var lv = 1
	func makeConnect(origin, object, target):
		object.connect(origin, self, target)
		cons.append({"origin":origin,"target":target, "object":object})

	func remove():
		for i in cons:
			i.object.disconnect(i.origin, self, i.target)
		if cdId != null:
			for i in tcha.skills:
				if i.id == cdId:
					tcha.skills.erase(i)
					break
	func setCha(cha):
		tcha = cha
	func _init(lv = 1):
		self.lv = lv

#----------------------------------------------001 双联381mm主炮----------------------------------------------
class Skill_001 extends Skill:
	func _init(lv):
		._init(lv)
		text = "炮击伤害25%几率翻倍"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and sys.rndPer(25):
			atkInfo.hurtVal *= 2

#----------------------------------------------002 双联装120mm炮Model1936----------------------------------------------
class Skill_002 extends Skill:
	func _init(lv):
		._init(lv)
		text = "造成雷击伤害时，赋予目标5层<烧蚀>"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.TORPEDO and atkInfo.hitCha.team != tcha.team:
			tcha.castBuff(atkInfo.hitCha, buff.b_shaoShi.new(5))

#----------------------------------------------003 双装120mm高平两用炮Mk11----------------------------------------------
class Skill_003 extends Skill:
	func _init(lv):
		._init(lv)
		text = "炮击命中后10%几率使鱼雷立即状态完毕"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and sys.rndPer(10):
			tcha.reloadSkill("torpedo")

#----------------------------------------------004 三联装152mm主炮----------------------------------------------
class Skill_004 extends Skill:
	func _init(lv):
		._init(lv)
		text = "每秒提高自身2%射速，最高100%"
	func setCha(cha):
		tcha = cha
		makeConnect("upS", tcha, "upS")
	func upS():
		var bf = tcha.hasBuff("b_152x3")
		if bf == null:
			tcha.addBuff(b_152x3.new())
		elif bf.att.spd < 1:
			bf.att.spd += 0.02
	class b_152x3:
		extends Buff
		var utils = globalData.infoDs["g_azurlaneUtils"]
		var dispel = 2
		var buffName = "三联装152mm主炮"
		func _init():
			att = utils.loadScript("AzurAtt")
			id = "b_152x3"
			
#----------------------------------------------005 155mm三连装炮----------------------------------------------
class Skill_005 extends Skill:
	func _init(lv):
		._init(lv)
		text = "本回合内，每次造成雷击伤害，提高10%雷击，最高150%"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.TORPEDO and tcha.attTurn.mgiAtkL < 1.5:
			tcha.attTurn.mgiAtkL += 0.1

#----------------------------------------------006 双联装203mmSKC主炮----------------------------------------------
class Skill_006 extends Skill:
	func _init(lv):
		._init(lv)
		text = "炮击额外造成目标血上限5%的伤害"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN:
			if atkInfo.hitCha.type == sys.CharaClass.BOSS:
				atkInfo.hurtVal += atkInfo.hitCha.att.maxHp * 0.005
			else:
				atkInfo.hurtVal += atkInfo.hitCha.att.maxHp * 0.04

#----------------------------------------------007 三联装203mm主炮Mk15----------------------------------------------
class Skill_007 extends Skill:
	func _init(lv):
		._init(lv)
		text = "造成炮击伤害时5%使目标<眩晕>2秒"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and sys.rndPer(5) and atkInfo.atkCha.team != atkInfo.hitCha.team:
			atkInfo.hitCha.addBuff(buff.b_xuanYun.new(2))

#----------------------------------------------008 三联406MM主炮MK6----------------------------------------------
class Skill_008 extends Skill:
	func _init(lv):
		._init(lv)
		text = "炮击伤害对目标周围(十字范围)产生40%溅射伤害"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and atkInfo.hitCha.team != tcha.team:
			for i in tcha.getCellChas(atkInfo.hitCha.cell, 1, 1):
				if i == atkInfo.hitCha:continue
				tcha.azurHurtChara(i, atkInfo.atkVal*0.4, sys.HurtType.WEAPON, sys.AtkType.EFF, "三联406MM主炮MK6")

#----------------------------------------------009 双联406MM主炮MK5----------------------------------------------
class Skill_009 extends Skill:
	func _init(lv):
		._init(lv)
		text = "炮击伤害无视目标25%装甲"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN:
			atkInfo.penL += 0.25

#----------------------------------------------010 五联装533mm磁性鱼雷----------------------------------------------
class Skill_010 extends Skill:
	func _init(lv):
		._init(lv)
		text = "鱼雷未命中时，恢复一半的鱼雷冷却"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.TORPEDO and atkInfo.skill == "鱼雷" and atkInfo.isMiss:
			var sk = tcha.getSkill("torpedo")
			sk.nowTime += (sk.cd * 0.5)

#----------------------------------------------011 四联装610mm鱼雷----------------------------------------------
class Skill_011 extends Skill:
	func _init(lv):
		._init(lv)
		text = "鱼雷10%几率造成5倍伤害"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.TORPEDO and sys.rndPer(10):
			atkInfo.hurtVal *= 5

#----------------------------------------------012 五联装533mm鱼雷Mk17----------------------------------------------
class Skill_012 extends Skill:
	func _init(lv):
		._init(lv)
		text = "造成雷击伤害时，获得伤害值30%的护盾"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.TORPEDO:
			tcha.changeShield(atkInfo.hurtVal*0.25)

#----------------------------------------------013 三联381mm主炮Model1934----------------------------------------------
class Skill_013 extends Skill:
	func _init(lv):
		._init(lv)
		text = "炮击伤害暴击时，赋予目标5层<灼烧>"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and atkInfo.isCri and atkInfo.hitCha.team != tcha.team:
			tcha.castBuff(atkInfo.hitCha, buff.b_zhuoShao.new(5))

#----------------------------------------------014 双联装203mm主炮Mle1931----------------------------------------------
class Skill_014 extends Skill:
	func _init(lv):
		._init(lv)
		text = "目标身上每层由装备者施加的负面状态使炮击伤害提高2%"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.GUN and atkInfo.hitCha.team != tcha.team:
			for i in atkInfo.hitCha.buffs:
				if not i is Item and i.get("life") != null and i.get("casCha") == tcha:
					atkInfo.factor += 0.02 * i.life

#----------------------------------------------015 四联装533mm磁性鱼雷----------------------------------------------
class Skill_015 extends Skill:
	func _init(lv):
		._init(lv)
		text = "鱼雷发射时，立即发起一次炮击"
	func setCha(cha):
		tcha = cha
		makeConnect("onCastCdSkill", tcha, "castCdSkill")
	func castCdSkill(id):
		if id == "torpedo":
			tcha.normalAtkChara(tcha.aiCha)

#----------------------------------------------016 五联装533mm鱼雷Mk9----------------------------------------------
class Skill_016 extends Skill:
	func _init(lv):
		._init(lv)
		text = "雷击伤害暴击时，对目标周围(十字)的敌人造成[雷击100%]的技能伤害"
	func setCha(cha):
		tcha = cha
		makeConnect("onAtkChara", tcha, "onAtkChara")
	func onAtkChara(atkInfo):
		if atkInfo.atkType == sys.AtkType.TORPEDO and atkInfo.isCri:
			for i in tcha.getCellChas(tcha.aiCha.cell, 1, 1):
				tcha.azurHurtChara(i, tcha.att.mgiAtk, sys.HurtType.WEAPON, sys.AtkType.SKILL, "五联装533mm鱼雷Mk9")